package com.ryskoo.catering.orderdetail.domain;

import com.ryskoo.common.hclconstant.CookStateEnum;
import com.ryskoo.framework.core.bean.BasicPO;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.text.DecimalFormat;

/**
 * 订单明细
 * @author BeHappy
 */
@Entity
@Table(name = "cater_order_detail")
public class OrderDetailPO extends BasicPO {

    private static final long serialVersionUID = -3924832609312629986L;

    private static final DecimalFormat df = new DecimalFormat("#0.00");

    /**
     * orderUuid
     */
    @Column(name = "order_uuid", columnDefinition = "char", length = 32)
    private String orderUuid;

    /**
     * 菜品Uuid
     */
    @Column(name = "product_uuid", columnDefinition = "char", length = 32)
    private String productUuid;

    /**
     * 菜品名称
     */
    @Column(name = "product_name", columnDefinition = "varchar", length = 32)
    private String productName;

    /**
     * 规格uuid
     */
    @Column(name = "sku_uuid", columnDefinition = "varchar", length = 32)
    private String skuUuid;

    /**
     * 展示的规格名称“大份 不辣”
     */
    @Column(name = "show_name", columnDefinition = "varchar", length = 100)
    private String showName;

    /**
     * 菜品价格
     */
    @Column(name = "product_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double productPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String productPriceStr;

    /**
     * 购买数量
     */
    @Column(name = "buy_num", columnDefinition = "int")
    private int buyNum;

    /**
     * 菜品总金额
     */
    @Column(name = "total_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double totalPrice;

    /**
     * 明细状态
     */
    @Column(name = "state", columnDefinition = "tinyint", length = 2)
    private int state;

    /**
     * 单品优惠券明细Uuid
     */
    @Column(name = "coupon_detail_uuid", columnDefinition = "char", length = 32)
    private String couponDetailUuid;

    /**
     * 优惠券优惠金额
     */
    @Column(name = "coupon_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double couponPrice;

    /**
     * 明细状态名称
     */
    @Transient
    private String stateName;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String totalPriceStr;

    /**菜品图片*/
    @Transient
    private String productImg;

    public String getOrderUuid() {
        return orderUuid;
    }

    public void setOrderUuid(String orderUuid) {
        this.orderUuid = orderUuid;
    }

    public String getProductUuid() {
        return productUuid;
    }

    public void setProductUuid(String productUuid) {
        this.productUuid = productUuid;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getSkuUuid() {
        return skuUuid;
    }

    public void setSkuUuid(String skuUuid) {
        this.skuUuid = skuUuid;
    }

    public String getShowName() {
        return showName;
    }

    public void setShowName(String showName) {
        this.showName = showName;
    }

    public double getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(double productPrice) {
        this.productPrice = productPrice;
    }

    public int getBuyNum() {
        return buyNum;
    }

    public void setBuyNum(int buyNum) {
        this.buyNum = buyNum;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getStateName() {
        return CookStateEnum.getNameByValue(this.state);
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public String getProductImg() {
        return productImg;
    }

    public void setProductImg(String productImg) {
        this.productImg = productImg;
    }

    public String getProductPriceStr() {
        return df.format(productPrice);
    }

    public String getTotalPriceStr() {
        return df.format(totalPrice);
    }


    public String getCouponDetailUuid() {
        return couponDetailUuid;
    }

    public void setCouponDetailUuid(String couponDetailUuid) {
        this.couponDetailUuid = couponDetailUuid;
    }

    public double getCouponPrice() {
        return couponPrice;
    }

    public void setCouponPrice(double couponPrice) {
        this.couponPrice = couponPrice;
    }

    @Override
    public String toString() {
        return "OrderDetailPO{" +
                "orderUuid='" + orderUuid + '\'' +
                ", productUuid='" + productUuid + '\'' +
                ", productName='" + productName + '\'' +
                ", skuUuid='" + skuUuid + '\'' +
                ", showName='" + showName + '\'' +
                ", productPrice=" + productPrice +
                ", productPriceStr='" + productPriceStr + '\'' +
                ", buyNum=" + buyNum +
                ", totalPrice=" + totalPrice +
                ", state=" + state +
                ", couponDetailUuid='" + couponDetailUuid + '\'' +
                ", couponPrice=" + couponPrice +
                ", stateName='" + stateName + '\'' +
                ", totalPriceStr='" + totalPriceStr + '\'' +
                ", productImg='" + productImg + '\'' +
                '}';
    }
}
